﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Automobile.service.BLL;
using Automobile.service.Model;

namespace Automobile.service.UI
{
    public partial class UpdateShipments : System.Web.UI.Page
    {
        ShipmentsBll bll = new ShipmentsBll();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["fid"] != null)
                {
                    LoadData();
                }
            }
        }

        private void LoadData()
        {
            this.TextBox1.Text = Request.QueryString["fid"].ToString();

            DataTable dt = bll.GetShipments(this.TextBox1.Text);
            if (dt != null)
            {
                 this.TextBox2.Text= dt.Rows[0][1].ToString();
                 this.TextBox3.Text= dt.Rows[0][2].ToString();
                 this.TextBox4.Text= dt.Rows[0][3].ToString();
                 this.TextBox5.Text = dt.Rows[0][4].ToString();
                 this.TextBox6.Text = dt.Rows[0][5].ToString();
                 this.TextBox7.Text = dt.Rows[0][6].ToString();
                 this.TextBox8.Text = dt.Rows[0][7].ToString();
                 this.TextBox9.Text = dt.Rows[0][8].ToString();
                 this.TextBox10.Text = dt.Rows[0][9].ToString();
                 this.TextBox11.Text = dt.Rows[0][10].ToString();
               
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ShipmentsModel s = new ShipmentsModel();

            s.Shipments_Id = Convert.ToInt32(this.TextBox1.Text);
            s.Shipments_blitems = this.TextBox2.Text.ToString();
            s.Shipments_data = Convert.ToDateTime(this.TextBox3.Text);
            s.Shipments_Per = this.TextBox4.Text.ToString();
            s.Shipments_Por = this.TextBox5.Text.ToString();
            s.Shipments_Peosor = this.TextBox6.Text.ToString();
            s.MemberCard_Id = Convert.ToInt32(this.TextBox7.Text);
            s.WareHose_Id = Convert.ToInt32(this.TextBox8.Text);
            s.Shipments_Price = Convert.ToInt32(this.TextBox9.Text);
            s.Shipments_Pricepor = Convert.ToInt32(this.TextBox10.Text);
            s.Shipments_Remark = this.TextBox11.Text.ToString();
            if (bll.UpdateShipmentsModel(s) > 0)
            {
                Response.Write("<script>alert('库房商品信息修改成功!');location.href='Shipments.aspx';</script>");
            }
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("Shipments.aspx");
        }
    }
}